package com.neuedu.collectionsdemo;

public class Student implements Comparable<Student> {
    //成员变量
    private String stuName;
    private String stuNum;
    private double stuScore;
    //行为方法
    //构造方法


    //继承自父接口的方法
    //实现了Comparable接口，则说明Student之间具有比较的行为能力；
    //实现Student排序的业务逻辑
    @Override
    public int compareTo(Student stu) {
        //默认值是相等的
        int reVal=0;
        //相等
        if (this.getStuScore()>stu.getStuScore()){
            //修改返回值
             reVal=1;

        }else if (this.getStuScore()<stu.getStuScore()){
            //修改返回值
            reVal=-1;

        }
        return reVal*-1;

    }

    public Student() {
    }

    public Student(String stuName, String stuNum, double stuScore) {
        this.stuName = stuName;
        this.stuNum = stuNum;
        this.stuScore = stuScore;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public String getStuNum() {
        return stuNum;
    }

    public void setStuNum(String stuNum) {
        this.stuNum = stuNum;
    }

    public double getStuScore() {
        return stuScore;
    }

    public void setStuScore(double stuScore) {
        this.stuScore = stuScore;
    }

    @Override
    public String toString() {
        return "Student{" +
                "stuName='" + stuName + '\'' +
                ", stuNum='" + stuNum + '\'' +
                ", stuScore=" + stuScore +
                '}';
    }
}
